package net.srcz.jsjvm.optim;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Vector;

public class DelayedProxy implements InvocationHandler {
	
	public class Invocation {
		Method method;
		Object[] args;
		public Invocation(Method m, Object[] args) {
			this.method = method;
			this.args = args;
		}
	}
	
	Object obj;
	public DelayedProxy(Object obj) {
		this.obj = obj;
	}
	
	List<Invocation> invocations = new Vector<Invocation>();
	
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		invocations.add(new Invocation(method,args));
		if(obj == null)
			return null;
		return method.invoke(obj, args);
	}
					

}
